package com.kfm.pm;

import java.util.Date;

public enum Greetings {

    // MORNING = new Greetings("早上好")
    MORNING("早上好"),
    NOON("中午好"),
    AFTERNOON("下午好"),
    EVENING("晚上好"),
    DAWN("凌晨好");

    private String message;

    Greetings(String message) {
        this.message = message;
    }
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}


class Test {

    public static void main(String[] args) {
        Date date = new Date();
        // [0, 23]
        date.setHours(20);
        int hour = date.getHours();
        Greetings greeting = null;
        if (hour > 6 && hour <= 10) {
            greeting = Greetings.MORNING;
        } else if (hour > 10 && hour <= 14) {
            greeting = Greetings.NOON;
        } else if (hour > 14 && hour <= 18) {
            greeting = Greetings.AFTERNOON;
        } else if (hour > 18 && hour <= 23) {
            greeting = Greetings.EVENING;
        } else {
            greeting = Greetings.DAWN;
        }

        System.out.println(greeting.getMessage());
    }
}
